﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Reflection;
using System.IO;
using System.Collections;

namespace TinyERP.Framework.Config
{
    /// <summary>
    /// Class contains all settings for application: Modules, ApplicationNodes,
    /// Locale setting, Navigation mode, Shortcuts
    /// </summary>
    public class ApplicationConfiguration
    {
        private static ApplicationConfiguration instance;
        private ApplicationConfiguration()
        {
            
            Modules = new List<ModuleElement>();
        }
        public static ApplicationConfiguration GetInstance()
        {
            if (instance == null)
            {
                instance = new ApplicationConfiguration();
            }
            return instance;
        }
        public ModuleElement GetModuleByKey(string key)
        {
            if (Modules == null || string.IsNullOrEmpty(key))
            {
                return null;
            }
            if (moduleDict == null)
            {
                moduleDict = new Hashtable();
                foreach (ModuleElement module in Modules)
                {
                    moduleDict[module.Name] = module;
                }
            }
            return (ModuleElement)moduleDict[key];
        }
       
        public IList<ModuleElement> Modules { get; set; }
        private Hashtable moduleDict;
        public string PluginPath { get; set; }
        public string ApplicationName { get; set; }
        public string NavigationView { get; set; }
        public string DefaultLanguage { get; set; }
        public string DefaultTheme { get; set; }
        public string NewShortcut { get; set; }
        public string DeleteShortcut { get; set; }
        public string EditShortcut { get; set; }
        public string CloseShortcut { get; set; }
        public string FindShortcut { get; set; }
        public string ApplicationMode { get; set; }
        public string CurrentVersion { get; set; }
        public string AutoUpdateURL { get; set; }
    }

    

}
